<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title>登录企业之家网管理系统</title>
    <meta name="description" content="企业之家网后台管理框架">
    <link href="${global_templets_skin}/systemstyle/style/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link href="${global_templets_skin}/systemstyle/style/font-awesome.min.css" rel="stylesheet"/>
    <link href="${global_templets_skin}/systemstyle/style/style.css" rel="stylesheet"/>
    <link href="${global_templets_skin}/systemstyle/style/login.min.css" rel="stylesheet"/>
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <link rel="shortcut icon" href="favicon.ico"/>
    <style type="text/css">label.error {
        position: inherit;
    }
    .layui-layer-dialog .layui-layer-content {
        color: #676a6c;
    }
    </style>
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location
        }
        ;
    </script>
</head>

<body class="signin">

<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1><img alt="企业之家网" src="${global_templets_skin}/systemstyle/images/logo.png"></h1>
                </div>
                <div class="m-b"></div>
                <h4>欢迎使用 <strong>企业之家 后台管理系统</strong></h4>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> SpringBoot</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Mybatis</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Shiro</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Thymeleaf</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> Bootstrap</li>
                </ul>
                <strong>还没有账号？ <a href="#">立即注册&raquo;</a></strong>
            </div>
        </div>
        <div class="col-sm-5">
            <form id="signupForm" lay-filter="" onclick="return false">
                <h4 class="no-margins">登录：</h4>
                <p class="m-t-md">你若不离不弃，我必生死相依</p>
                <input type="text" name="username" id="username" class="form-control uname" lay-verify="username" placeholder="用户名" value=""/>
                <input type="password" name="password" id="password" class="form-control pword" lay-verify="password" placeholder="密码" value=""/>
                <div class="row m-t">
                    <div class="col-xs-6">
                        <input type="text" name="captcha" id="captcha" class="form-control code" lay-verify="captcha" placeholder="验证码" maxlength="4" autocomplete="off">
                    </div>
                    <div class="col-xs-6">
                        <img id="code" src="/captcha/gif_captcha.do" class="imgcode" onclick="reloadCode();" width="85%"/>
                    </div>
                </div>
                <div class="checkbox-custom">
                    <input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
                </div>
                <button class="btn btn-success btn-block" lay-submit lay-filter="formDemo" id="btnSubmit"
                        data-loading="正在验证登录，请稍后...">登录
                </button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">
            &copy; 2019 All Rights Reserved. 企业之家网 <br>
        </div>
    </div>
</div>
<script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer;
        element.render();
        //登陆
        $('#btnSubmit').click(function () {
            var username = $('#username').val();
            var password = $('#password').val();
            var captcha = $('#captcha').val();
            if (username == "" || username == null) {
                layer.msg('用户名不能为空', {icon: 2});
                return false;
            } else if (password == "" || password == null) {
                layer.msg('密码不能为空', {icon: 2});
                return false;
            } else if (captcha == "" || captcha == null) {
                layer.msg('验证码不能为空', {icon: 2});
                return false;
            }
            //console.log(username);
            //debugger;
            $.ajax({
                url: "/system/login.do",
                data: {'username': username, 'password': password, 'captcha': captcha},
                type: "post",
                dataType: 'json',
                cache: false,
                async: false,
                error: function (i, g, h) {
                    layer.msg('发送错误', {icon: 2});
                },
                success: function (data) {
                    if (data.code == '0') {
                        window.location.href = "/admin/index.do";
                    } else {
                        layer.msg(data.message, {icon: 2});
                    }
                    document.getElementById('code').setAttribute('src', '/captcha/gif_captcha.do?' + Math.random());
                },
                error: function (data) {
                    alert("出错：" + data.message);
                }
            });
        });
    });


    //重新加载验证码
    function reloadCode() {
        var code = document.getElementById('code');
        code.setAttribute('src', '/captcha/gif_captcha.do?' + Math.random());
    }
</script>
</body>
</html>
